package com.cai.io.demo;

import java.io.*;

public class FileCopyDemo {
    public static void main(String[] args) throws IOException {
        File file=new File("demo.txt");
        long fileSize = file.length();
        FileInputStream fis = new FileInputStream(file);
        FileOutputStream fos=new FileOutputStream("demo_cp.txt");
        int n;
        byte[] data = new byte[(int)fileSize];
        while ((n=fis.read(data))!=-1){
            fos.write(data,0,n);
        }
        fis.close();
        fos.close();
    }
}
